<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:body>
        <div class="change_pass">
            <f:view>
                <h:form>

                    <script type="text/javascript">
                            function confirmation() {
                                  var answer = confirm("Do you want Save?")
                                  if (answer){
                                      return true;
                                  }
                                  else{
                                      return false;
                                  }
                            }
                    </script>


                    <h3 style="color: #3F8AAC; margin:  10px 0 10px 25px;">
                        Enter the keyword :    <h:inputText style="font-family: Arial;font-size: 13px;"  value="#{interviewsManagedBean.name}"
                                                            valueChangeListener="#{interviewsManagedBean.findIDApplicant}">
                            <f:ajax  event="keyup" render="ajaxOutput" />
                        </h:inputText> &nbsp;
                        <h:selectOneMenu style="font-family: Arial;font-size: 13px;"   value="#{interviewsManagedBean.select}" valueChangeListener="#{interviewsManagedBean.setQuery}">
                            <f:ajax event="change"/>
                            <f:selectItem itemLabel="---Select---" itemValue="0" ></f:selectItem>
                            <f:selectItem itemLabel="Applicant ID" itemValue="1" ></f:selectItem>
                            <f:selectItem itemLabel="Applicant Name" itemValue="2"></f:selectItem>
                        </h:selectOneMenu>
                    </h3>

                    <p:dataTable id="ajaxOutput" value="#{interviewsManagedBean.listApplicant}" var="item"
                                 paginator="true" rows="10"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                 rowsPerPageTemplate="5,10,15">

                        <f:facet name="header">

                        </f:facet>

                        <p:column  sortBy="#{item.applicantName}">
                            <f:facet  name="header">
                                <h:outputText  value="Applicant Name" />
                            </f:facet>
                            <h:commandLink action="#{applicantManagedBean.applicantDetails(item)}" value="#{item.applicantName}" >
                                <f:setPropertyActionListener value="#{item}" target="#{applicantManagedBean.applicant}"  />
                            </h:commandLink>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Phone" />
                            </f:facet>
                            <p:inplace>
                                <p:inputText size="11" value="${item.appPhone}" />
                            </p:inplace>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Email" />
                            </f:facet>
                            <p:inplace>
                                <p:inputText size="20" value="${item.appEmail}" />
                            </p:inplace>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Date of Create" />
                            </f:facet>
                            <h:outputText value="#{item.doc}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Status" />
                            </f:facet>
                            <h:selectOneMenu disabled="true" value="${item.appStatus}">
                                <f:selectItem  itemLabel="---Select---" itemValue="0" ></f:selectItem>
                                <f:selectItem itemLabel="Not in Process" itemValue="1" ></f:selectItem>
                                <f:selectItem itemLabel="In Process" itemValue="2"></f:selectItem>
                                <f:selectItem itemLabel="Hired" itemValue="3"></f:selectItem>
                                <f:selectItem itemLabel="Banned" itemValue="4"></f:selectItem>
                            </h:selectOneMenu>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value=""/>
                            </f:facet>

                            <p:commandLink rendered="#{item.appStatus !=3 and item.appStatus!=4}" onclick="dailogModal.show();"  update="panelGrid,display" actionListener="#{vacancyManagedBean.renderPopup}" style="margin-right:20px;">
                                <f:attribute name="value" value="attach" />
                                <f:attribute name="demo" value="#{item.applicantID}" />
                            </p:commandLink>
                        </p:column>
                    </p:dataTable>
                    <table>
                        <tr>
                            <td style="text-align: left;">
                                <h:commandButton onclick="return confirmation();" value="Save" action="#{applicantManagedBean.updateApplicant}"/>
                            </td>
                        </tr>
                    </table>
                </h:form>

            </f:view>
        </div>
        <script type="text/javascript">

       function showMe (it, box) {
         var vis;
         if(!box.checked){
            vis="hidden";
         }else{
             vis="visible";
         }
         document.getElementById(it).style.visibility = vis;
       }
        </script>
        <f:view>
            <p:dialog id="dl" header="Schedule Interview" minHeight="200"  closable="false" draggable="false" widgetVar="dailogModal" modal="true" resizable="false" width="510" height="350">


                <h:panelGrid id="display" columns="2">
                    <h:form>
                        <script type="text/javascript">
                            function confirattack() {
                                  var answer = confirm("Do you want Submit?")
                                  if (answer){
                                      return true;
                                  }
                                  else{
                                      return false;
                                  }
                            }
                        </script>
                        <h:outputText style="color: red;" value="#{vacancyManagedBean.message}" id="checkVacancy" />
                        <table border="0" width="450px" cellpadding="3" cellspacing="1">
                            <tr>
                                <td width="150" align="left">Applicant Code :  </td>
                                <td><h:outputText value="#{vacancyManagedBean.app.applicantID}" /></td>

                            </tr>
                            <tr>
                                <td align="left">Applicant Name : </td>
                                <td ><h:outputText value="#{vacancyManagedBean.app.applicantName}" /></td>
                            </tr>

                            <tr>
                                <td align="left"> Department :  </td>
                                <td>
                                    <h:selectOneMenu valueChangeListener="#{vacancyManagedBean.findValueChange}" >
                                        <f:selectItems value="#{vacancyManagedBean.listItemDepart}" ></f:selectItems>
                                        <f:ajax event="valueChange" render="out" />
                                        <f:ajax event="valueChange" render="outEmploy" />
                                    </h:selectOneMenu>
                                </td>
                            </tr>

                            <tr>
                                <td align="left"> Vacancy :  </td>
                                <td>
                                    <h:selectOneMenu id="out" style="width: 210px" value="#{vacancyManagedBean.va.vacancyID}" valueChangeListener="#{vacancyManagedBean.findVacancyChange}" >
                                        <f:selectItems value="#{vacancyManagedBean.vaRender}" ></f:selectItems>
                                        <f:ajax event="valueChange" render="checkVacancy" />
                                    </h:selectOneMenu>

                                </td>
                            </tr>
                            <tr>
                                <td align="left"> Interviewer Code :  </td>
                                <td>
                                    <h:selectOneMenu id="outEmploy" style="width: 210px" value="#{vacancyManagedBean.emp.empNo}" >
                                        <f:selectItems value="#{vacancyManagedBean.listEmp}" ></f:selectItems>
                                    </h:selectOneMenu>
                                </td>
                            </tr>

                            <tr>
                                <td align="left">Schedule Interview  </td>
                                <td>
                                    <h:selectBooleanCheckbox onclick="showMe('div1',this);" value="true" >

                                    </h:selectBooleanCheckbox>
                                </td>
                            </tr>
                        </table>

                        <div id="div1" style="width: 100%;" >
                            <table border="0">
                                <tr>
                                    <td width="150" align="left">
                                        Interview Date :
                                    </td>
                                    <td>
                                        <p:calendar value="#{vacancyManagedBean.inter.scheduleDate}" label="true" readOnlyInputText="true">
                                            <f:convertDateTime pattern="MM/dd/yyyy" />
                                        </p:calendar>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="left">Start Time : </td>
                                    <td><h:inputText size="5" id="txtSTime" value="#{vacancyManagedBean.inter.startTime}"/> hours</td>
                                </tr>

                            </table>
                        </div>
                        <h:commandButton value="Submit" onclick="return confirattack()" action="#{vacancyManagedBean.addScheduleInterview}" >

                        </h:commandButton>

                        <h:commandButton value="Cancel" onclick="dailogModal.hide();" type="button"/>
                    </h:form>
                </h:panelGrid>

            </p:dialog>
        </f:view>
    </h:body>
</html>

